package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by adhulip on 3/4/14.
 */
public class BibliotecaApp {
    private Library library;
    private Menu menu;
    private BibliotecaInputManager inputManager;
    private final String welcomeMessage = "Welcome to the library!";
    private Printer printer;


    public static void main(String[] args) {
        List<String> listOfBooks = new ArrayList<String>(
                Arrays.asList("Book A", "Book B"));
        Library library = new Library(listOfBooks);
        Printer printer = new Printer();
        OptionManager optionManager = new OptionManager();


        BibliotecaInputManager inputManager = new BibliotecaInputManager(new BufferedReader(new InputStreamReader(System.in)));
        new BibliotecaApp(printer, new Menu(printer, library, inputManager, optionManager), library).go();
    }

    public BibliotecaApp(Printer printer, Menu menu, Library library){
        this.printer = printer;
        this.menu = menu;
        this.library = library;
        this.inputManager = inputManager;
    }

    public void go() {
        printWelcomeMessage();
        printer.render(library);
        menu.render();
        menu.start();
    }

    private void printWelcomeMessage() {
        printer.render(welcomeMessage);
    }

}
